/****************************************************************************
 *  _____       ______  _____
 * |_   _|     |  ____|/ ____|
 *   | |  _ __ | |__  | (___    Institute of Embedded Systems
 *   | | | '_ \|  __|  \___ \   Zürcher Hochschule für Angewandte
 *  _| |_| | | | |____ ____) |  Wissenschaften
 * |_____|_| |_|______|_____/   8401 Winterthur, Switzerland
 *
 ****************************************************************************
 *
 * @version $Rev: 201 $
 * @author  $Author: bacr $
 * @date    $Date: 2013-12-13 14:07:22 +0100 (ven., 13 déc. 2013) $
 *
 ***************************************************************************/

#ifndef __PTP2_MASTER_H__
#define __PTP2_MASTER_H__

typedef struct ptp2_master_t    ptp2_master_t;

#include "object.h"

#include "hcpp/ptp2_task_queue.h"
#include "hcpp/ptp2_types.h"
#include "hcpp/ptp2_datasets.h"
#include "hcpp/ptp2_port.h"
#include "hcpp/ptp2_bmc_algorithm.h"

#include "spi/spi_master.h"

#include "hal/tod_itf.h"

struct ptp2_master_t {
    object_t                    obj;

    bool                        running;

    /* datasets */
    ptp2_default_ds_t           default_ds;
    ptp2_current_ds_t           current_ds;
    ptp2_parent_ds_t            parent_ds;
    ptp2_time_properties_ds_t   time_properties_ds;

    ptp2_port_t                 port;
    ptp2_bmc_algorithm_t        bmc_algorithm;

    spi_master_t                spi_master;

    tod_itf_t                   tod;
    ptp2_task_t                 task_tod;

    ptp2_task_t                 task_osc_drift;
    ptp2_task_t                 task_hw_monitoring;

    /* debug */
    /* === OSCILLOSCOPE === */
    ptp2_task_t                 task_debug_osc;
    ptp2_task_t                 task_debug_blinky;
};

bool                    ptp2_master_init(void);
bool                    ptp2_master_mainloop(void);


//ptp2_task_queue_t      *ptp2_master_get_task_queue(void);

#endif

